package com.simple.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import com.simple.configuration.interceptor.BasePathIntercepter;

/**
 * web基础配置
 */
@Configuration
public class WebConfiguration extends WebMvcConfigurationSupport {
	
    //设置默认跳转页面到登录
    @Override
    protected void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
    }

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/templates/");
    }

	@Override
	protected void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new BasePathIntercepter()).addPathPatterns("/**");
		super.addInterceptors(registry);
	}
    
    

}
